from ronglian_sms_sdk import SmsSDK
import json

accId = '2c94811c9035ff9f01907235fa310b6c'
accToken = '5b0606c75912484886943a0cb3582d63'
appId = '2c94811c9035ff9f01907235fbb60b73'




def send_message(phone,code):
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1'
    mobile = phone
    datas = (code,)
    resp = sdk.sendMessage(tid, mobile, datas)
    print(resp)
    if(str(json.loads(resp).get("statusCode")) == "000000"):
        return True
    else:
        return False



#发送短信
# def getPhone(phone):
#     return 12345


# 000000	请求成功
# 172001	网络错误


from .pay import AliPay


def get_alipay():
    # 初始化支付实例

    # 公共参数
    # 沙箱环境地址：https://openhome.alipay.com/platform/appDaily.htm?tab=info
    app_id = "9021000138690594"  # APPID （沙箱应用）

    # 支付完成后，支付偷偷向这里地址发送一个post请求，识别公网IP,如果是 192.168.20.13局域网IP ,支付宝找不到，def page2() 接收不到这个请求
    notify_url =  "http://localhost:8000/home/nav/alipaycallback/"

    # 支付完成后，跳转的地址。
    return_url = "http://localhost:8000/home/nav/alipaycallback/"

    merchant_private_key_path = "home/tools/keys/private.txt"  # 应用私钥
    alipay_public_key_path = "home/tools/keys/public.txt"  # 支付宝公钥

    alipay = AliPay(
        appid=app_id,
        app_notify_url=notify_url,
        return_url=return_url,
        app_private_key_path=merchant_private_key_path,
        alipay_public_key_path=alipay_public_key_path,  # 支付宝的公钥，验证支付宝回传消息使用，不是你自己的公钥
        debug=True,  # 默认False,
    )
    return alipay